using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace WPFServices.Converters
{
    /// <summary>
    /// 状态转可见性转换器
    /// 当状态为1（未分解）时显示，其他状态隐藏
    /// </summary>
    public class StatusToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
                return Visibility.Collapsed;

            int status;
            if (value is int)
                status = (int)value;
            else if (value is int?)
                status = ((int?)value).GetValueOrDefault();
            else
                return Visibility.Collapsed;

            return status == 1 ? Visibility.Visible : Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
} 